<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
    <meta name="csrf-token" content="{{ csrf_token() }}">
	<link rel="stylesheet" href="/shop/style/css/ch-ui.admin.css">
	<link rel="stylesheet" href="/shop/style/font/css/font-awesome.min.css">
    <script type="text/javascript" src="/shop/style/js/jquery.js"></script>
    <script type="text/javascript" src="/shop/style/js/ch-ui.admin.js"></script>
    <link rel="stylesheet" href="/houtai/layui/css/layui.css">
    <link rel="stylesheet" href="/shop/style/css/page.css">
    <script src="/houtai/layui/layui.js"></script>
    <style>
        .tc{
            text-align:center;
        }
        a{
            color:#1963aa;
        }
    </style>
</head>
<body>
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="#">首页</a> &raquo; <a href="#">商城管理</a> &raquo; 品牌列表
    </div>
    <!--面包屑导航 结束-->

	<!--结果页快捷搜索框 开始-->
	<div class="search_wrap">
        <form action="" method="post">
            <table class="search_tab">
                <tr>
                    {{--<th width="120">选择分类:</th>--}}
                  <!--   <td>
                        <select onchange="javascript:location.href=this.value;">
                            <option value="">全部</option>
                            <option value="http://www.baidu.com">百度</option>
                            <option value="http://www.sina.com">新浪</option>
                        </select>
                    </td> -->
                    <th width="70">关键字:</th>
                    <td><input type="text" name="keywords" placeholder="关键字" value="{{$keywords}}"></td>
                    <td><input type="submit" name="sub" value="查询" id="check"></td>
                </tr>
            </table>
        </form>
    </div>
    <!--结果页快捷搜索框 结束-->

    <!--搜索结果页面 列表 开始-->
    <form action="#" method="post">
        <div class="result_wrap">
            <!--快捷导航 开始-->
            <div class="result_content">
                <div class="short_wrap">
                    <a href="/shop/brand/add"><i class="fa fa-plus"></i>新增品牌</a>
                    <a href="javascript:void(0);" onClick="tong()"><i class="fa fa-exchange"></i>一键同步</a>

                </div>
            </div>
            <!--快捷导航 结束-->
        </div>

        <div class="result_wrap">
            <div class="result_content">
                <table class="list_tab">
                    <tr>
                        <th>ID</th>
                        <th>品牌(中文)</th>
                        <th>品牌(英文)</th>
                        <th>是否同步</th>
                        <th>操作</th>
                    </tr>
                    @if($list->isEmpty())
                        <tr>
                            <td colspan="5" class="tc">暂无数据</td>
                        </tr>
                    @else
                        @foreach ($list as $v)
                            <tr>
                                <td>{{$v->id}}</td>
                                <td>
                                    {{$v->name_cny}}
                                </td>
                                <td>{{$v->name_en}}</td>
                                <td>@if($v->state == 1)是 @else 否 @endif</td>
                                <td>
                                    <a href="/shop/brand/edit?id={{$v->id}}">修改</a>
                                    <a href="javascript:void(0);" onClick="del({{$v->id}})">删除</a>
                                </td>
                            </tr>
                        @endforeach
                    @endif

                </table>

                {{--<div class="page_list">--}}
                    {{--<ul>--}}
                        {{--<li class="active"><a href="#">1</a></li>--}}
                        {{--<li><a href="#">2</a></li>--}}
                        {{--<li><a href="#">3</a></li>--}}
                        {{--<li><a href="#">4</a></li>--}}
                        {{--<li><a href="#">5</a></li>--}}
                        {{--<li><a href="#">&raquo;</a></li>--}}
                    {{--</ul>--}}
                {{--</div>--}}
            </div>
            <div id="pull_right">
                <!--分页写法-->
                <div class="pull-right">
                    {{ $list->appends(['keywords'=>$keywords])->render() }}
                </div>
            </div>
        </div>
        <input type="hidden" name="keywords" value="{{$keywords}}">
        <input type="hidden" name="page" value="{{$page}}">
    </form>
    <!--搜索结果页面 列表 结束-->

    <script>
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        function del(id){
            layui.use('layer', function() {
                var keywords = $("input[name=keywords]").val();
                var page = $("input[name=page]").val();
                layer.confirm('确定删除?', {icon: 3, title: '提示'}, function (index) {
                    $.ajax({
                        url:'/shop/brand/del',
                        type:'post',
                        async:false,
                        data:{id:id},
                        success:function(msg){
                            layer.msg(msg['msg']);
                            location.href="/shop/brand/index?keywords="+keywords+'&page='+page;
                        },
                    })
                });
            });
        }

        $("#check").click(function(){
            var keywords = $("input[name=keywords]").val();
                location.href='/shop/brand/index?keywords='+keywords;
        })

        function tong(){
            layui.use('layer', function() {
                var keywords = $("input[name=keywords]").val();
                var page = $("input[name=page]").val();
                layer.confirm('确定一键同步?', {icon: 3, title: '提示'}, function (index) {
                    $.ajax({
                        url:'/shop/brand/synchro',
                        type:'post',
                        async:false,
                        success:function(msg){
                            layer.msg(msg['msg']);
                            location.href="/shop/brand/index?keywords="+keywords+'&page='+page;
                        },
                    })
                });
            });
        }

    </script>

</body>
</html>